package cn.us.eagle.generic.service.impl;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import cn.us.eagle.generic.dao.BaseDao;
import cn.us.eagle.generic.service.BaseService;

/**
 * 继承式泛型Service实现类
 * 
 * @author ReasonZhong
 * 
 * @param <T>
 *            泛型类
 * @param <PK>
 *            泛型类主键
 */
public class BaseServiceImpl<T, PK extends java.io.Serializable> implements
		BaseService<T, PK> {

	protected final Log log = LogFactory.getLog(getClass());

	protected BaseDao<T, PK> baseDao;

	public BaseServiceImpl(final BaseDao<T, PK> baseDao) {
		this.baseDao = baseDao;
	}

	@Override
	public PK save(T model) {
		return this.baseDao.save(model);
	}

	@Override
	public void saveOrUpdate(T model) {
		this.baseDao.saveOrUpdate(model);
	}

	@Override
	public void update(T model) {
		this.baseDao.update(model);
	}

	@Override
	public void merge(T model) {
		this.baseDao.merge(model);
	}

	@Override
	public void delete(PK id) {
		this.baseDao.delete(id);
	}

	@Override
	public void deleteObject(T model) {
		this.baseDao.deleteObject(model);
	}

	@Override
	public T get(PK id) {
		return this.baseDao.get(id);
	}

	@Override
	public int countAll() {
		return this.baseDao.countAll();
	}

	@Override
	public List<T> listAll() {
		return this.baseDao.listAll();
	}

	@Override
	public boolean isExists(PK id) {
		return this.baseDao.isExists(id);
	}

	@Override
	public void flush() {
		this.baseDao.flush();
	}

	@Override
	public void clear() {
		this.baseDao.clear();
	}

}
